home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / srefv12i.zip / srefconf.cmd < prev    next >
OS/2 REXX Batch file  |  1997-03-04  |  73KB  |  2,300 lines

  1. /* this the "simple" sre-filter configurator */
  2.  
  3. srefconf:
  4.  
  5. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  6.  
  7. /* the background color */
  8. USECOLOR='3def5f'
  9.  
  10. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  11.  
  12.  
  13. parse arg  ddir, tempfile, action,list,verb ,uri,user, ,
  14.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  15.          servername,host_nickname,homedir
  16.  
  17. if verb=" " then do
  18.    say "The SRE-Filter simple configurator is not meant to be run in standalone mode "
  19.    exit
  20. end  /* Do */
  21.  
  22. host_nickname=strip(upper(host_nickname))
  23.  
  24. call okay_client
  25. if notokay=1 then return rstatus||' Simple Configurator: Client not allowed access '
  26.  
  27.  
  28. optlist='ADD_HOST REMOVE_HOST CHECKLOG LOGON_FAIL_FILE ADD_USER REMOVE_USER '
  29. OPTLIST=OPTLIST||' ADD_INHOUSE REMOVE_INHOUSE ALLOW_ACCESS DO_HTACCESS ACCESS_FAIL_FILE '
  30. OPTLIST=OPTLIST||' ADD_ACESS REMOVE_ACCESS DEFAULT_ACCESS AUTO_NAME NOT_FOUND_URL '
  31. OPTLIST=OPTLIST||' THE_REALM HOME_NAME HOME_DIR ADD_VIRTUAL REMOVE_VIRTUAL INDEX '
  32. OPTLIST=OPTLIST||' WRITE_LOGS RECORD_OPTION HIT_CACHE_LEN HIT_OWNER_SUPPRESS ADD_ACCESS'
  33. OPTLIST=OPTLIST||' SSI_SHTML_ONLY HEADERS  WEBMASTER ADD_CUSTOM REMOVE_CUSTOM '
  34. OPTLIST=OPTLIST||' NO_SS ADD_REDIRECT REMOVE_REDIRECT SSI_CACHE_ON  '
  35. OPTLIST=OPTLIST||' FIX_EXPIRE  SMTP_GATEWAY ADD_PUBLICURL REMOVE_PUBLICURL  '
  36.  
  37. /* intitialize possible arguments */
  38. arglist.!show=0 ;arglist.!set=0
  39.  
  40.  
  41. /* get argument list */
  42.  
  43. do until list=""
  44.   parse var list a1 '&' list
  45.   parse  var a1 atype '=' aval ; aval=strip(aval); atype=upper(strip(atype))
  46.   foo='!'||atype
  47.   arglist.foo=aval
  48. end /* do */
  49.  
  50. foo=sref_expire_response(-1)   /* suppress immediate expire ? */
  51.  
  52. /* if SHOW argument, then return the appropriate request form */
  53. if arglist.!show<>0 then do
  54.    ares=show_it(arglist.!show)
  55.    return ares
  56. end  /* Do */
  57.  
  58. /* if SET argument, then go make the change*/
  59. if arglist.!set<>0 then do
  60.     ares=set_it(arglist.!set)   /*expose arglist */
  61.     return ares
  62. end  /* Do */
  63.  
  64. 'nodata'
  65.  
  66. return '400 0 Simple configurator '
  67.  
  68. /****************************/
  69. /*Change a parameter */
  70. /* based on stuff returned by client's response to show_it generated forms */
  71. set_it:procedure expose ddir optlist verbose servername enmadd host_nickname  basedir arglist. tempfile
  72. parse upper arg theopt
  73. ddir=strip(translate(ddir,'\','/'),'t','\')||'\'
  74. crlf='0d0a'x
  75. redo=1
  76.  
  77. initfile=get_value('initfilt_file')
  78. workdata=get_value('workdata_dir')
  79.  
  80. if wordpos(theopt,optlist)=0 then do
  81.   foo=responsecf('badreq','Configure',' You selected an unknown parameter: '||theopt)
  82.    return 0 
  83. end   
  84.  
  85. /* for each of the possible entries in optlist */
  86. select
  87.    when theopt="CHECKLOG" then do
  88.       aval='YES'
  89.       if arglist.!yesno=0 then aval='NO'
  90.       foo=change_initfilt(theopt,aval)
  91.       wow=change_okay(foo,'Client Logon Requirement','LOGON')
  92.    end
  93.  
  94.  
  95.    when theopt="LOGON_FAIL_FILE" then do
  96.       aval='LOGFAIL.HTM'
  97.       if arglist.!yesno=0 then aval='0'
  98.       foo=change_initfilt(theopt,aval)
  99.       wow=change_okay(foo,'Use Logon-Failure Response File ','LOGON')
  100.    end
  101.  
  102.    when theopt="ALLOW_ACCESS" then do
  103.       aval='YES'
  104.       if arglist.!yesno=1 then aval='INHOUSE'
  105.       foo=change_initfilt(theopt,aval)
  106.       wow=change_okay(foo,'Check SEL-specific Access Controls  ','ACCESS')
  107.    end
  108.  
  109.   when theopt="DO_HTACCESS" then do
  110.       aval='YES'
  111.       if arglist.!yesno=0 then aval='NO'
  112.       foo=change_initfilt(theopt,aval)
  113.       wow=change_okay(foo,'Enable HTACCESS Method','ACCESS')
  114.   end
  115.  
  116.    when theopt="ACCESS_FAIL_FILE" then do
  117.       aval='ACCFAIL.HTM'
  118.       if arglist.!yesno=0 then aval='0'
  119.       foo=change_initfilt(theopt,aval)
  120.       wow=change_okay(foo,'Use Access-Failure Response File ','ACCESS')
  121.    end
  122.  
  123.  
  124.    when theopt="THE_REALM" then do
  125.       aval=arglist.!thevalue
  126.       aval=translate(aval,' ','+'||'00090a0d'x)
  127.       aval=packur(aval)
  128.       foo=change_initfilt(theopt,aval)
  129.       wow=change_okay(foo,'Default Realm ','NAMES')
  130.   end
  131.  
  132.    when theopt="HOME_NAME" then do
  133.       aval=arglist.!thevalue
  134.       aval=translate(aval,' ','+'||'00090a0d'x)
  135.       aval=packur(aval)
  136.       foo=change_initfilt(theopt,aval)
  137.       wow=change_okay(foo,'Colloquial Name of Site ','NAMES')
  138.   end
  139.  
  140.    when theopt="INDEX" then do
  141.       aval=arglist.!thevalue
  142.       if upper(aval)="OTHER"  then aval=arglist.!ownvalue
  143.       aval=packur(aval)
  144.       foo=change_initfilt(theopt,aval)
  145.       wow=change_okay(foo,'Default Document ','DEFAULT')
  146.   end
  147.  
  148.    when theopt="AUTO_NAME" then do
  149.       mkit=" "
  150.       if symbol('arglist.!thevalue1')='VAR' then mkit=mkit||' INDEX.HTM '
  151.       if symbol('arglist.!thevalue2')='VAR' then mkit=mkit||' INDEX.HTML '
  152.       if symbol('arglist.!thevalue3')='VAR' then mkit=mkit||' *.HTM '
  153.       if symbol('arglist.!thevalue4')='VAR' then mkit=mkit||' *.HTML '
  154.       if symbol('arglist.!thevalue5')='VAR' then do
  155.             foo=translate(arglist.!thevalue5,' ','+')
  156.             mkit=mkit||' '||foo
  157.       end
  158.       if symbol('arglist.!thevalue6')='VAR' then  mkit=mkit||' !DIR  '
  159.       if symbol('arglist.!thevalue6a')='VAR' then do /* autodesecirbe */
  160.           diro=get_value('DIR_OPTIONS')
  161.           oo="" ; gota=0
  162.           do until diro=""
  163.               parse var diro v1 diro
  164.               if abbrev(upper(v1),'AUTO_DESCRIBE')=1 then do
  165.                  oo=oo||' '||'AUTO_DESCRIBE='||arglist.!thevalue6a||' '
  166.                  gota=1
  167.               end
  168.               else do
  169.                  oo=oo||' '||v1
  170.              end
  171.           end
  172.           if gota=0 then do
  173.                  oo=oo||' '||'AUTO_DESCRIBE='||arglist.!thevalue6a||' '
  174.           end  /* Do */
  175.       end /* do */
  176.       foo=change_initfilt(theopt,mkit)
  177.       foo=change_initfilt('DIR_OPTIONS',oo)
  178.       wow=change_okay(foo,' Directory Specific Default Document ','DIRS')
  179.   end
  180.  
  181.  when theopt="NOT_FOUND_URL" then do
  182.       aval=arglist.!thevalue
  183.       aval=translate(aval,' ','+'||'00090a0d'x)
  184.       aval=packur(aval)
  185.       foo=change_initfilt(theopt,aval)
  186.       wow=change_okay(foo,'Not Found Document Response ','DEFAULT')
  187.  end
  188.      
  189.    when theopt="HOME_DIR" then do
  190.       aval=arglist.!thevalue
  191.       aval=translate(aval,' ','+'||'00090a0d'x)
  192.       aval2=arglist.!thevalue2
  193.       aval2=translate(aval2,' ','+'||'00090a0d')
  194.       if aval2=' ' then do
  195.           mkit=aval
  196.       end
  197.       else do
  198.          mkit=translate(aval,'/','\')
  199.          mkit=strip(aval,'t','/')||'/$/'
  200.          AVAL2=translate(aval2,'/','\')
  201.          mkit=mkit||strip(aval2,'l','/')
  202.       end  /* Do */
  203.       foo=change_initfilt(theopt,mkit)
  204.       wow=change_okay(foo,'Home Directory','DIRS')
  205.   end
  206.  
  207.    when theopt="RECORD_OPTION" then do
  208.       aval='YES'
  209.       if arglist.!record=2 then aval='FILE'
  210.       if arglist.!record=0 then aval='NO'
  211.       foo=change_initfilt(theopt,aval)
  212.       wow=change_okay(foo,'Recording option ','RECORD')
  213.   end
  214.  
  215.  
  216.    when theopt="HIT_CACHE_LEN" then do
  217.       aval='5'
  218.       if arglist.!yesno=0 then aval=0
  219.       if arglist.!yesno=2  then aval='FILE'
  220.       foo=change_initfilt(theopt,aval)
  221.       wow=change_okay(foo,'Type of Repetitive Hits Cache','RECORD')
  222.   end
  223.  
  224.    when theopt="HIT_OWNER_SUPPRESS" then do
  225.       aval='YES'
  226.       if arglist.!yesno=0 then aval='NO'
  227.       foo=change_initfilt(theopt,aval)
  228.       wow=change_okay(foo,'Suppress Recording OWNER Requests','RECORD')
  229.    end
  230.  
  231.    when theopt="WRITE_LOGS" then do
  232.       aval='YES'
  233.       if arglist.!yesno=0 then aval='NO'
  234.       foo=change_initfilt(theopt,aval)
  235.       wow=change_okay(foo,'Enable Common-Log Audit File','RECORD')
  236.    end
  237.  
  238.  
  239.  
  240.   when theopt="SSI_SHTML_ONLY" then do
  241.       aval='YES'
  242.       if arglist.!yesno=0 then aval='NO'
  243.       foo=change_initfilt(theopt,aval)
  244.       wow=change_okay(foo,'SSI on SHTML Only','SSI')
  245.    end
  246.  
  247.   when theopt="SSI_CACHE_ON" then do
  248.       aval='YES'
  249.       if arglist.!yesno=0 then aval='NO'
  250.       foo=change_initfilt(theopt,aval)
  251.       wow=change_okay(foo,'SSI CACHE Enable','SSI')
  252.    end
  253.  
  254.  
  255.  when theopt="WEBMASTER" then do
  256.       aval=arglist.!thevalue
  257.       aval=translate(aval,' ','+'||'00090a0d'x)
  258.       aval=packur(aval)
  259.       foo=change_initfilt(theopt,aval)
  260.       wow=change_okay(foo,'WEBMASTER  ','SSI')
  261.  end
  262.  
  263.    when theopt="FIX_EXPIRE" then do
  264.       aval='0.05'
  265.       if arglist.!yesno=0 then aval=0
  266.       foo=change_initfilt(theopt,aval)
  267.       wow=change_okay(foo,'Suppress Immediate Expiration','MISC')
  268.   end
  269.  
  270.  when theopt="NO_SS" then do
  271.       no_ssi='NO'
  272.       if arglist.!no_ssi then no_ssi='YES'
  273.  
  274.       no_proc='NO' ; no_code='NO'
  275.       if arglist.!no_ssp=1 then no_proc='YES'
  276.       if arglist.!no_ssp=11 then   no_code='YES'
  277.  
  278.       foo1=change_initfilt('NO_INCLUDE',no_ssi)
  279.       foo2=change_initfilt('NO_PROCESSING',no_proc,1)
  280.       foo=change_initfilt('NO_INTERPRET_CODE',no_code,1)
  281.        wow=change_okay(foo,'Suppress SSP and SSI ','MISC')
  282.  
  283.  
  284.  end  /* Do */
  285.  
  286.  when theopt="SMTP_GATEWAY" then do
  287.       aval=arglist.!thevalue
  288.       aval=translate(aval,' ','+'||'00090a0d'x)
  289.       aval=packur(word(aval,1))
  290.       foo=change_initfilt(theopt,aval)
  291.       wow=change_okay(foo,'SMTP_GATEWAY ','MISC')
  292.  end
  293.  
  294.  when theopt="HEADERS" then do
  295.   
  296. /* sepearte at crlfs */
  297.      ahead=packur(translate(arglist.!header,' ','+'))
  298.      afoot=packur(translate(arglist.!footer,' ','+'))
  299.      nhead=0
  300.      do until ahead=""
  301.         parse var ahead aline (crlf) ahead ; 
  302.         aline=strip(translate(aline,' ','000d0a'x))
  303.         if aline="" then iterate
  304.         nhead=nhead+1
  305.         headers.nhead=aline
  306.      end /* do */
  307.      nfoot=0
  308.      do until afoot=""
  309.         parse var afoot aline (crlf) afoot 
  310.         aline=strip(translate(aline,' ','000d0a'x))
  311.         if aline="" then iterate
  312.         nfoot=nfoot+1
  313.         footers.nfoot=aline
  314.      end /* do */
  315.      if nhead>0 then do
  316.          foo1=change_initfilt('HEADERS.1',headers.1)
  317.          do mm=2 to nhead
  318.              foo1=change_initfilt('HEADERS.'||mm,headers.mm,1)
  319.          end /* do */
  320.          nhead=nhead+1
  321.          foo=change_initfilt('HEADERS.'||nhead,0,1)
  322.      end
  323.      else do
  324.          nhead=1
  325.          foo=change_initfilt('HEADERS.1',0)
  326.      end
  327.      /* trash old headers */
  328.      foo1='1' ; joe=nhead
  329.      do until foo1<>'1'
  330.          joe=joe+1
  331.          foo1=change_initfilt('HEADERS.'||joe,,,1)
  332.      end /* do */
  333.      if nFOOT>0 then do
  334.          foo1=change_initfilt('FOOTERS.1',FOOTers.1,1)
  335.          do mm=2 to nFOOT
  336.              foo1=change_initfilt('FOOTERS.'||mm,FOOTers.mm,1)
  337.          end /* do */
  338.          nfoot=nfoot+1
  339.          foo=change_initfilt('FOOTERS.'||nFOOT,0,1)
  340.      end
  341.      else do
  342.          nfoot=1
  343.          foo=change_initfilt('FOOTERS.1',0,1)
  344.      end
  345.      foo1='1' ; joe=nfoot        /* remove old footers */
  346.      do until foo1<>'1'
  347.          joe=joe+1
  348.          foo1=change_initfilt('FOOTERS.'||joe,,,1)
  349.      end /* do */
  350.  
  351.      wow=change_okay(foo,'HEADER and FOOTER ','SSI')
  352.  end  /* Do */
  353.  
  354.  
  355.  when theopt="ADD_INHOUSE" then do
  356.     foo=strip(translate(arglist.!user,' ','+'))
  357.     foo2=strip(translate(arglist.!privs,' ','+'))
  358.     aval=word(foo,1)||' '||foo2
  359.     foo=change_stem('INHOUSEIPS.',aval)
  360.     wow=change_okay(foo,'Add an In-House User','LOGON')
  361.  end  /* Do */
  362.  
  363.  when theopt="ADD_HOST" then do
  364.     foo=strip(translate(arglist.!host,' ','+'))
  365.     foo2=strip(translate(arglist.!nickname,' ','+'))
  366.     foo3=packur(strip(translate(arglist.!datadir,' ','+')))
  367.     aval=word(foo,1)||', '||word(foo2,1)||', '||word(foo3,1)
  368.     foo=change_stem('HOSTS.',upper(aval))
  369.     wow=change_okay(foo,'Add a Host Identification','HOST')
  370.  end  /* Do */
  371.  
  372.  when theopt="REMOVE_INHOUSE" then do
  373.     remlist=make_removes()
  374.     foo=change_stem('INHOUSEIPS.',,upper(remlist))
  375.      foo1='1' ; joe=nkill       /* remove old footers */
  376.      do until foo1<>'1'
  377.          joe=joe+1
  378.          foo1=change_initfilt('INHOUSEIPS.'||joe,,,1)
  379.      end /* do */
  380.  
  381.     wow=change_okay(foo,'Remove In-House Users','LOGON',mess2)
  382.  end  /* Do */
  383.  
  384.  
  385.  when theopt="ADD_PUBLICURL" then do
  386.     foo=strip(translate(arglist.!url,' ','+'))
  387.     isliteral=0 ; norecord=0
  388.     if symbol('ARGLIST.!LITERAL')='VAR' then 
  389.         isliteral=arglist.!literal
  390.     if symbol('ARGLIST.!NORECORD')='VAR' then 
  391.        norecord=arglist.!norecord
  392.     select
  393.        when isliteral=1 & norecord=1 then   foo2='LITERAL_NORECORD'
  394.        when isliteral=1 then foo2='LITERAL'
  395.        when norecord=1 then foo2='NORECORD'
  396.        otherwise foo2=' '
  397.     end
  398.     aval=word(foo,1)||' '||foo2
  399.     foo=change_stem('PUBLIC_URLS.',aval)
  400.     wow=change_okay(foo,'Add PUBLIC Area Identifier','PUBLICURL')
  401.  end  /* Do */
  402.  
  403.  
  404.  when theopt="REMOVE_PUBLICURL" then do
  405.     remlist=make_removes()
  406.     foo=change_stem('PUBLIC_URLS.',,upper(remlist))
  407.     foo1='1' ; joe=inlist       /* remove old footers */
  408.     do until foo1<>'1'
  409.          joe=joe+1
  410.          foo1=change_initfilt('PUBLIC_URLS.'||joe,,,1)
  411.     end /* do */
  412.  
  413.     wow=change_okay(foo,'Remove PUBLIC Areas Identifier','PUBLICURL',mess2)
  414.  end  /* Do */
  415.  
  416.  
  417.  
  418.  
  419.  when theopt="REMOVE_HOST" then do
  420.     remlist=make_removes()
  421.     foo=change_stem('HOSTS.',,upper(remlist))
  422.     wow=change_okay(foo,'Remove Host Identification Entries','HOST',mess2)
  423.  end  /* Do */
  424.  
  425.  when theopt="ADD_USER" then do
  426.      foo1=translate(upper(strip(arglist.!user)),' ','+')
  427.      foo1=word(foo1,1)
  428.      foo2=translate(upper(strip(arglist.!pwd)),' ','+')
  429.      foo2=word(foo2,1)
  430.      foo3=translate(upper(strip(arglist.!privs)),' ','+')
  431.      if foo3=' 'then foo3='NEWUSER'
  432.      aval=foo1' 'foo2' 'foo3
  433.     foo=change_file('USER_FILE',aval)
  434.     wow=change_okay(foo,'Add Users','LOGON')
  435.  end  /* Do */
  436.  
  437.  when theopt="REMOVE_USER" then do
  438.     remlist=make_removes()
  439.     foo=change_file('USER_FILE',,upper(remlist))
  440.     wow=change_okay(foo,'Remove Users','LOGON',mess2)
  441.  end  /* Do */
  442.  
  443.  when theopt="ADD_ACCESS" then do
  444.     plist=' '
  445.     tenp='NO_SSI NO_CODE NO_SSP CACHE PUT DELETE NO_HTACCESS NO_VIRTUAL NO_ALIAS NO_POSTFILTER'
  446.     do po=1 to 10
  447.         axx=strip(word(tenp,po))
  448.         if symbol('ARGLIST.!'||axx)="VAR" then do
  449.              plist=plist||' '||axx
  450.         end  /* Do */
  451.     end /* do */
  452.     foo1=translate(upper(strip(arglist.!url)),' ','+')
  453.     foo1=word(foo1,1)
  454.     foo2=translate(upper(strip(arglist.!privs)),' ','+')
  455.     if foo2=' ' then foo2='*'
  456.     foo3=translate(upper(strip(arglist.!realm)),' ','+')
  457.     foo4=translate(upper(strip(arglist.!failfile)),' ','+')
  458.      aval=foo1' 'foo2' , ' plist ' , 'foo3' , ' foo4
  459.     foo=change_file('ACCESS_FILE',aval)
  460.     wow=change_okay(foo,'Add Access Control Entry','ACCESS')
  461.  end  /* Do */
  462.  
  463.  
  464.  
  465.  
  466.  when theopt="DEFAULT_ACCESS" then do
  467.      foo1=translate(upper(strip(arglist.!defprivs)),' ','+')
  468.      if foo1=' ' then foo1='*'
  469.      aval='/* '||foo1
  470.     foo=change_file('ACCESS_FILE',aval,'/* ')
  471.     wow=change_okay(foo,'Change Default Access Control Entry','ACCESS')
  472.  end  /* Do */
  473.  
  474.  
  475.  when theopt="REMOVE_ACCESS" then do
  476.     remlist=make_removes()
  477.     foo=change_file('ACCESS_FILE',,upper(remlist))
  478.     wow=change_okay(foo,'Remove Access Control Entry','ACCESS',mess2)
  479.  end  
  480.  
  481.  when theopt="ADD_VIRTUAL" then do
  482.      foo1=translate(upper(strip(arglist.!url)),' ','+')
  483.      foo1=word(foo1,1)
  484.      foo2=translate(upper(strip(arglist.!directory)),' ','+')
  485.      foo2=word(foo2,1)
  486.      foo2=translate(foo2,'\','/')
  487.      foo2=strip(foo2,'t','\')||'\* '
  488.      aval=foo1' 'foo2
  489.     foo=change_file('VIRTUAL_FILE',aval,,,1)
  490.     wow=change_okay(foo,'Add Virtual Directory Entry','DIRS')
  491.  end  
  492.  
  493.  when theopt="REMOVE_VIRTUAL" then do
  494.     remlist=make_removes()
  495.     foo=change_file('VIRTUAL_FILE',,upper(remlist))
  496.     wow=change_okay(foo,'Remove Virtual Directory  Entry','DIRS',mess2)
  497.  end  
  498.  
  499.  
  500.  when theopt="ADD_REDIRECT" then do
  501.      foo1=translate(upper(strip(arglist.!url)),' ','+')
  502.      foo1=word(foo1,1)
  503.      foo2=translate(strip(arglist.!newurl),' ','+')
  504.      foo2=word(foo2,1)
  505.      aval=foo1' 'foo2
  506.     foo=change_file('ALIAS_FILE',aval)
  507.     wow=change_okay(foo,'Add  Redirection Alias Entry','DIRS')
  508.  end  
  509.  
  510.  when theopt="REMOVE_REDIRECT" then do
  511.     remlist=make_removes()
  512.     foo=change_file('ALIAS_FILE',,upper(remlist))
  513.     wow=change_okay(foo,'Remove Redirection Alias  Entry','DIRS',mess2)
  514.  end  
  515.  
  516.  when theopt="ADD_CUSTOM" then do
  517.      foo1=translate(upper(strip(arglist.!variable)),' ','+')
  518.      foo1=word(foo1,1)
  519.      foo2=packur(translate(strip(arglist.!value),' ','+'))
  520.      if host_nickname<>' ' then foo1=foo1||'.'||host_nickname
  521.      aval=foo1' 'foo2
  522.      took=host_nickname
  523.      host_nickname=' '
  524.     foo=change_file('REPSTRGS_FILE',aval)
  525.     host_nickname=took
  526.  
  527.     wow=change_okay(foo,'Add  Custom Replacement Variable','SSI')
  528.  
  529.  end  
  530.  
  531.  when theopt="REMOVE_CUSTOM" then do
  532.     remlist=make_removes()
  533.     took=host_nickname
  534.     if host_nickname<>' ' then do
  535.        arf=""
  536.        do until remlist=""
  537.           parse var remlist a1 remlist
  538.           a1=strip(a1)||'.'||host_nickname||' '
  539.        end
  540.        remlist=a1
  541.     end /* do */
  542.     host_nickname=' '
  543.     foo=change_file('REPSTRGS_FILE',,upper(remlist),,,1)
  544.     host_nickname=took
  545.  
  546.     wow=change_okay(foo,'Remove Redirection Alias  Entry','SSI',mess2)
  547.  end  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  otherwise do
  554.       string ' Modification n.a. for ' theopt
  555.       redo=0 ; wow='200 40 '
  556.  end
  557.  
  558.  
  559. end  /* select */
  560.  
  561. /* signal srefmon to refresh values ? */
  562. if redo=1 then  foo=value('SREF_REDO',1,'os2environment')
  563.  
  564.  
  565. return wow
  566.  
  567. /****************************/
  568. /* make a "removes" list from arglist.!delete.n entres */
  569. make_removes:procedure expose arglist.
  570.  
  571. ndo=arglist.!entries
  572. arf=""
  573. do mm =1 to ndo
  574.    aa='!DELETE.'||mm
  575.    oo=symbol('ARGLIST.'||aa)
  576.    if oo<>'VAR' then iterate
  577.    arf=arf||' '||arglist.aa
  578. end
  579. return arf
  580.  
  581.  
  582. /****************************/
  583. /* modify a parameter in the initfilt file */
  584.  
  585. change_initfilt:procedure expose  verbose servername enmadd host_nickname  basedir initfile
  586. parse arg aopt,aval0,noupdate,noadd
  587. aopt=strip(upper(aopt)); aval0=strip(aval0)
  588. if noupdate=' ' then noupdate=0
  589. if noadd=' ' then noadd=0
  590. foo=fileread(initfile,dalines,,'E')
  591. if dalines.0=0 then return 'Could not read:'||initfile
  592.  
  593. aval0=sref_replacestrg(aval0,"'","''",'ALL')
  594.  
  595. foundit=0
  596.  
  597.  
  598. /* scan through, looking for parameter that matches aopt.
  599. Also, must be same host nickname.  Retain all non matches in 
  600. same order. If match, delete, and rewrite at end of file.
  601. Copy old file to xxx.BAK (overwrite old xxx.bak if it exists) */
  602.  
  603. inew=0
  604. do mm=1 to dalines.0
  605.    aline=strip(upper(dalines.mm))
  606.    if aline=" " | abbrev(aline,';')=1 then do /* retain comments */
  607.        inew=inew+1
  608.        newlines.inew=dalines.mm
  609.        iterate
  610.    end
  611.    if abbrev(aline,aopt)=0 then do  /* non match, retain */
  612.        inew=inew+1
  613.        newlines.inew=dalines.mm
  614.        iterate
  615.    end
  616. /* correct name, but is it correct host */
  617.    parse var aline avar '=' aval
  618.    avar=translate(avar,' ','.')
  619.    nw=words(avar)
  620.    if host_nickname<>' ' then do  /* see if it matches this host nickname */
  621.      if nw=1  then do /* no host nickname, can't match */
  622.           inew=inew+1
  623.           newlines.inew=dalines.mm
  624.           iterate
  625.       end
  626.       if strip(upper(word(avar,nw)))<>host_nickname then do /* does not match this host */
  627.           inew=inew+1
  628.           newlines.inew=dalines.mm
  629.           iterate
  630.       end
  631.    end
  632.    else do              /* generic site */
  633.        if nw>1 &  datatype(word(avar,nw))<>'NUM' then do /* host specific parameter */
  634.           inew=inew+1
  635.           newlines.inew=dalines.mm
  636.           iterate
  637.        end
  638.    end
  639. /* if here, a match. so skip it (and rewrite at end of list */
  640.    foundit=1
  641.  
  642. end
  643.  
  644. /* if nosuch paramter, and noadd mode, return */
  645. if noadd=1 & foundit=0 then return 0  /* signal no more */
  646.  
  647. if noadd=0 then do      /* add new value, if noadd=0 */
  648.   inew=inew+1
  649.   if host_nickname<>' ' then
  650.       isvar=aopt||'.'||host_nickname
  651.   else
  652.      isvar=aopt
  653.    newlines.inew=isvar||"='"||aval0||"'"
  654. end
  655. newlines.0=inew
  656.  
  657.  
  658. if noupdate<>1 then do
  659.    bakfile=initfile                /* create a .bak file */
  660.    foo=lastpos('.',bakfile)
  661.    if foo=0  then
  662.       bakfile=bakfile||'.bak'
  663.    else
  664.       bakfile=delstr(bakfile,foo)||'.bak'
  665.    wow=doscopy(initfile,bakfile,'R')
  666.    if wow<>0 then do
  667.       say " ERROR: backup copy could not be made, error code  " wow
  668.       return 'Backup copy could not be made'
  669.   end  /* Do */
  670. end
  671.  
  672. /* now write new results */
  673. foo=filewrite(initfile,newlines,'R')
  674.  
  675. if foo=0 then  return 'Could not save parameters file '  
  676. return 1  /* success */
  677.  
  678.  
  679.  
  680.  
  681. /****************************/
  682. /* modify a parameter in the initfilt file */
  683.  
  684. change_stem:procedure expose  verbose servername enmadd host_nickname  basedir initfile mess2 inlist nkill
  685. parse arg lookfor, newval,remlist
  686.  
  687. foo=fileread(initfile,dalines,,'E')
  688. if dalines.0=0 then return 'Could not read:'||initfile
  689. nkill=0
  690.  
  691. /* scan through, looking for inhouseips or other stem  parameters,
  692. of the appropriate host.  Pull them, and add or remove
  693. */
  694.  
  695. inew=0
  696. ninh=0
  697. do mm=1 to dalines.0
  698.    aline=strip(upper(dalines.mm))
  699.    if aline=" " | abbrev(aline,';')=1 then do /* retain comments */
  700.        inew=inew+1
  701.        newlines.inew=dalines.mm
  702.        iterate
  703.    end
  704.    if abbrev(aline,lookfor)=0 then do  /* non match, retain */
  705.        inew=inew+1
  706.        newlines.inew=dalines.mm
  707.        iterate
  708.    end
  709.  
  710. /* correct name, but is it correct host */
  711.    parse var aline avar '=' aval
  712.    avar=translate(avar,' ','.')
  713.    nw=words(avar)
  714.    if host_nickname<>' ' then do  /* see if it matches this host nickname */
  715.       if strip(upper(word(avar,nw)))<>host_nickname then do /* does not match this host */
  716.           inew=inew+1
  717.           newlines.inew=dalines.mm
  718.           iterate
  719.       end
  720.    end
  721.    else do              /* generic site */
  722.        if datatype(word(avar,nw))<>'NUM' then do /* host specific parameter */
  723.           inew=inew+1
  724.           newlines.inew=dalines.mm
  725.           iterate
  726.        end
  727.    end
  728.  
  729. /* if here, a match. If remlist=' ', then temp record and  skip it (and rewrite at end of list
  730.    of remlist<>' ', then keep only if not in remlist */
  731.    aval=strip(strip(aval),,'"')
  732.    aval=strip(aval,,"'")
  733.    if aval=0 | aval=" " then iterate /* ignore end flags */
  734.    if remlist<>' ' then do
  735.        w1=upper(strip(word(translate(aval,' ',','),1)))
  736.        if wordpos(w1,remlist)>0  then do 
  737.           nkill=nkill+1
  738.           iterate
  739.        end  /* Do */
  740.    end
  741.    ninh=ninh+1   /* else, keep it*/
  742.    inhs.ninh=aval
  743. end
  744.  
  745. if newval<>' ' then do /* add the new one */
  746.    ninh=ninh+1
  747.    inhs.ninh=newval
  748. end
  749.  
  750. /* fix up form to save */
  751. do ii=1 to ninh
  752.  if host_nickname<>' ' then do
  753.      bval=inhs.ii
  754.      inhs.ii=lookfor||ii||'.'||host_nickname||"='"||bval||"'"
  755.   end /* do */
  756.   else do
  757.      bval=inhs.ii
  758.      inhs.ii=lookfor||ii||"='"||bval||"'"
  759.   end  /* Do */
  760. end
  761. ninh=ninh+1
  762. if host_nickname<>' ' then do
  763.   inhs.ninh=lookfor||host_nickname||'.'||ninh||'=0'
  764. end
  765. else do
  766.   inhs.ninh=lookfor||ninh||'=0'
  767. end
  768.  
  769. do mm=1 to ninh
  770.    inew=inew+1
  771.    newlines.inew=inhs.mm
  772. end /* do */
  773.  
  774. newlines.0=inew
  775.  
  776. if noupdate<>1 then do
  777.    bakfile=initfile                /* create a .bak file */
  778.    foo=lastpos('.',bakfile)
  779.    if foo=0  then
  780.       bakfile=bakfile||'.bak'
  781.    else
  782.       bakfile=delstr(bakfile,foo)||'.bak'
  783.    wow=doscopy(initfile,bakfile,'R')
  784.    if wow<>0 then do
  785.       say " ERROR: backup copy could not be made, error code  " wow
  786.       return 'Backup copy could not be made'
  787.   end  /* Do */
  788. end
  789.  
  790. /* now write new results */
  791. foo=filewrite(initfile,newlines,'R')
  792.  
  793. if foo=0 then  return 'Could not save parameters file '  
  794.  
  795. mess2=' Number entries deleted: '||nkill
  796. inlist=ninh
  797. return 1  /* success */
  798.  
  799.  
  800.  
  801.  
  802. /****************************/
  803. /* tell client status of parameter change */
  804. change_okay:procedure expose tempfile 
  805. parse arg status,whatis,jumpto,mess2
  806. if status<>1 then
  807.   text='Problem modifying: '||whatis
  808. else
  809.   text='Success modifying: '||whatis
  810.  
  811.  call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  812.  call lineout tempfile, "<html><head><title>"text"</title></head><body>"
  813.  if status=1 then do
  814.    call lineout tempfile,' <h2> ' whatis ' successfully modified </h2> '
  815.    call lineout tempfile,' Modification will take effect in approximately 15 seconds '
  816.  if mess2<>' ' then call lineout tempfile,'<br>  <em> ' mess2 '</em> '
  817.  end
  818.  else do
  819.    call lineout tempfile,' <h2>Sorry,  ' whatis ' could not be modified </h2> '
  820.    call lineout tempfile,' Problem: ' status
  821.  end
  822.  call lineout tempfile,'<hr> <a href="/config0.htm#'jumpto'">Return to simple configurator </a>'
  823.  call lineout tempfile, '</body><html>'
  824.  call lineout tempfile
  825. oof=dosdir(tempfile,'s')
  826.  'FILE ERASE TYPE text/html NAME ' tempfile
  827.  return '200 '||oof
  828.  
  829.  
  830. /****************************/
  831. /* Load, modify, and return a parameter modification form */
  832. /* uses templates in the config_dir directory */
  833. show_it:procedure expose ddir optlist verbose servername enmadd host_nickname  basedir tempfile usecolor 
  834. parse upper  arg theopt
  835. crlf='0d0a'x
  836.  
  837. ok=0
  838. ddir=strip(translate(ddir,'\','/'),'t','\')||'\'
  839. workdata=get_value('workdata_dir')
  840.  
  841. thedir=get_value('CONFIG_DIR')
  842. if thedir=' ' then
  843.    thedir=ddir||'CONFIGS'
  844.  
  845. if dosisdir(thedir)=0 then do
  846.    'STRING Bad Setup: no CONFIG_DIR directory: ' thedir
  847.    return 0
  848. end  /* Do */
  849.  
  850. if wordpos(theopt,optlist)=0 then do
  851.   foo=responsecf('badreq','Configure',' You selected an unknown parameter ')
  852.    return 0
  853. end    */
  854.  
  855. /* grab a file, and modify it, based on theopt */
  856. select
  857.  when theopt='ADD_HOST' then do
  858.      ok=GET_IT('ADDHOST')
  859.      ok=make_doc(theopt,1,'HOST')
  860.  end    
  861.  
  862.  when theopt='REMOVE_HOST' then do
  863.     ok=GET_IT('REMHOST')
  864.     foo=make_hosts('initfilt_file')
  865.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  866.     foo=get_value('initfilt_file')
  867.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  868.     ok=make_doc(theopt,1,'HOST')
  869.  end    
  870.  
  871.  when theopt='CHECKLOG' then do
  872.       ok=GET_IT('CHECKLOG')
  873.       ok=do_yesno('CHECKLOG','N','YES Y 1 ALWAYS INHOUSE ')
  874.       ok=make_doc(theopt,0,'LOGON')
  875.  end    
  876.  
  877.  
  878.  
  879.  when theopt='LOGON_FAIL_FILE' then do
  880.       ok=GET_IT('LOGFAIL')
  881.       ok=do_yesno('LOGON_FAIL_FILE','Y')
  882.       stuff=a_replacestrg(stuff,'$SERVDIR',basedir,'ALL')
  883.       ok=make_doc(theopt,0,'LOGON')
  884.  end    
  885.  
  886.  when theopt='ADD_USER' then do
  887.       ok=GET_IT('ADDUSER')
  888.       foo=get_value('USER_FILE')
  889.       stuff=a_replacestrg(stuff,'$USER_FILE',foo,'ALL')
  890.       ok=make_doc(theopt,0,'LOGON')
  891.  end    
  892.  
  893.  when theopt='REMOVE_USER' then do
  894.     ok=GET_IT('REMUSER')
  895.     foo=make_users('USER_FILE')
  896.     if foo=0 then return 0
  897.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  898.     foo=get_value('user_file')
  899.     stuff=a_replacestrg(stuff,'$user_file',foo,'ALL')
  900.     ok=make_doc(theopt,0,'LOGON')
  901.  end    
  902.  
  903.  when theopt='ADD_INHOUSE' then do
  904.      ok=GET_IT('ADDINH')
  905.       foo=get_value('USER_FILE')
  906.       stuff=a_replacestrg(stuff,'$USER_FILE',foo,'ALL')
  907.       ok=make_doc(theopt,0,'LOGON')
  908.  end    
  909.  
  910.  when theopt='REMOVE_INHOUSE' then do
  911.      ok=GET_IT('REMINH')
  912.      foo=make_inhouseips('initfilt_file')
  913.      if foo=0 then return 0
  914.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  915.     foo=get_value('initfilt_file')
  916.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  917.  
  918.     ok=make_doc(theopt,0,'LOGON')
  919.  end    
  920.  
  921.  when theopt='ADD_PUBLICURL' then do
  922.       ok=GET_IT('ADDPURL')
  923.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  924.       foo=get_value('initfilt_file')
  925.       stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  926.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  927.       ok=make_doc(theopt,0,'PUBLICURL')
  928.  end    
  929.  
  930.  when theopt='REMOVE_PUBLICURL' then do
  931.      ok=GET_IT('REMPURL')
  932.      foo=make_puburls('initfilt_file')
  933.      if foo=0 then return 0
  934.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  935.     foo=get_value('initfilt_file')
  936.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  937.  
  938.     ok=make_doc(theopt,0,'PUBLICURL')
  939.  end    
  940.  
  941.  when theopt='ALLOW_ACCESS' then do
  942.       ok=GET_IT('ALLOWAC')
  943.       ok=do_yesno('ALLOW_ACCESS','Y','Y YES 1 INHOUSE ')
  944.       ok=make_doc(theopt,0,'ACCESS')
  945.  end    
  946.  
  947.  
  948.  when theopt='DO_HTACCESS' then do
  949.       ok=GET_IT('HTACCESS')
  950.       ok=do_yesno('DO_HTACCESS','N')
  951.       ok=make_doc(theopt,0,'ACCESS')
  952.  end    
  953.  
  954.  
  955.  when theopt='ACCESS_FAIL_FILE' then do
  956.       ok=GET_IT('ACCFAIL')
  957.       ok=do_yesno('ACCESS_FAIL_FILE','Y')
  958.       stuff=a_replacestrg(stuff,'$SERVDIR',basedir,'ALL')
  959.       ok=make_doc(theopt,0,'ACCESS')
  960.  end    
  961.  
  962.  when theopt='ADD_ACCESS' then do
  963.       ok=GET_IT('ADDACC')
  964.       foo=get_value('ACCESS_FILE')
  965.       stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  966.       ok=make_doc(theopt,0,'ACCESS')
  967.  end    
  968.  
  969.  
  970.  when theopt='REMOVE_ACCESS' then do
  971.     ok=GET_IT('REMACC')
  972.     foo=make_access('ACCESS_FILE')
  973.     if foo=0 then return 0
  974.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  975.     foo=get_value('access_file')
  976.     stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  977.     ok=make_doc(theopt,0,'ACCESS')
  978.  end    
  979.  
  980.  when theopt='DEFAULT_ACCESS' then do
  981.     ok=GET_IT('DEFACC')
  982.     foo=make_access('ACCESS_FILE',1)
  983.    if foo=0 then return 0
  984.     stuff=a_replacestrg(stuff,'$default_access',stuff2,'ALL')
  985.     foo=get_value('access_file')
  986.     stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  987.     ok=make_doc(theopt,0,'ACCESS')
  988.  end    
  989.  
  990.  
  991.  
  992.  WHEN THEOPT="INDEX" then DO
  993.      ok=get_it('DEFAULT')
  994.      adef=strip(upper(get_value('DEFAULT')))
  995.      select
  996.        when adef="INDEX.HTM" then do
  997.           adef1='CHECKED' ; adef2=' ' ; adef3=' ' ;afile=' '
  998.        end  /* Do */
  999.        when adef="INDEX.HTML" then do
  1000.          adef1=' ' ; adef2='CHECKED' ; adef3=' '; afile=' '
  1001.        end  /* Do */
  1002.        otherwise do
  1003.          adef1=' ' ; adef2=' ' ; adef3='CHECKED' ; afile=adef
  1004.        end
  1005.       end
  1006.       stuff=a_replacestrg(stuff,'$HTMINDEX',adef1,'ALL')
  1007.       stuff=a_replacestrg(stuff,'$HTMLINDEX',adef2,'ALL')
  1008.       stuff=a_replacestrg(stuff,'$INDEXOTHER',adef3,'ALL')
  1009.       stuff=a_replacestrg(stuff,'$INDEXfile',afile,'ALL')
  1010.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1011.      ok=make_doc(theopt,0,'DEFAULT')
  1012.  end  /* Do */
  1013.  
  1014.  when theopt='AUTO_NAME' then do
  1015.    ok=get_it('autoname')
  1016.    adef=strip(upper(get_value('AUTO_NAME'))) 
  1017.    oks='INDEX.HTM INDEX.HTML *.HTM *.HTML !CREATE !DIR'
  1018.    oks2='$htmindex $htmlindex $htmdirname $htmldirname $createdir $dir_dir '
  1019.    other=""
  1020.    do mm=1 to words(oks)
  1021.       a1=strip(word(oks,mm))
  1022.       ado=strip(word(oks2,mm))
  1023.       tt=wordpos(a1,adef)
  1024.       if tt=0 then do
  1025.            adef1=' '
  1026.       end
  1027.       else do
  1028.            adef1='checked'
  1029.            adef=delword(adef,tt,1)
  1030.       end
  1031.  
  1032.       stuff=a_replacestrg(stuff,ado,adef1,'ALL')
  1033.    end
  1034.    stuff=a_replacestrg(stuff,'$other',adef,'ALL')
  1035.  
  1036.    ok=strip(upper(get_value('DIR_OPTIONS')))
  1037.    autodno='checked' ; autodyes=' '
  1038.    if (wordpos('AUTO_DESCRIBE',ok)+wordpos('AUTO_DESCRIBE=1',ok))>0 then do
  1039.           autodno=' '; autodyes='checked'; 
  1040.    end
  1041.    stuff=a_replacestrg(stuff,'$AUTODNO',autodno,'ALL')
  1042.    stuff=a_replacestrg(stuff,'$AUTODYES',autodyes,'ALL')
  1043.  
  1044.    ok=make_doc(theopt,0,'DEFAULT')
  1045.  end    
  1046.  
  1047.  when theopt='NOT_FOUND_URL' then do
  1048.     ok=GET_IT('notfound')
  1049.     tt=get_value('NOT_FOUND_URL')
  1050.     tt=a_replacestrg(tt,'<','<','ALL')
  1051.     tt=a_replacestrg(tt,'>','>','ALL')
  1052.     tt=a_replacestrg(tt,'"','"','ALL')
  1053.     stuff=a_replacestrg(stuff,'$not_found_url',tt,'ALL')
  1054.     ok=make_doc(theopt,0,'DEFAULT')
  1055.  end    
  1056.  
  1057.  when theopt='THE_REALM' then do
  1058.     ok=GET_IT('realmnam')
  1059.     tt=get_value('THE_REALM')
  1060.     stuff=a_replacestrg(stuff,'$therealm',tt,'ALL')
  1061.     ok=make_doc(theopt,0,'NAMES')
  1062.  end    
  1063.  
  1064.  when theopt='HOME_NAME' then do
  1065.     ok=GET_IT('homename')
  1066.     tt=get_value('HOME_NAME')
  1067.     stuff=a_replacestrg(stuff,'$home_name',tt,'ALL')
  1068.     ok=make_doc(theopt,0,'NAMES')
  1069.  end    
  1070.  
  1071.  when theopt='HOME_DIR' then do
  1072.     ok=GET_IT('homedir')
  1073.     tt=get_value('HOME_DIR',0,'DIRS')
  1074.     ms=pos('$',tt)
  1075.     if ms=0 then do
  1076.        hd1=tt ; hd2=' '
  1077.     end  /* Do */
  1078.     else do
  1079.        hd1=substr(tt,1,ms-1) ;hd2=substr(tt,ms+2)
  1080.     end  /* Do */
  1081.  
  1082.     stuff=a_replacestrg(stuff,'$home_DIR',hd1,'ALL')
  1083.     stuff=a_replacestrg(stuff,'$home_subDIR',hd2,'ALL')
  1084.  
  1085.     ok=make_doc(theopt,0,'DIRS')
  1086.  end    
  1087.  
  1088.  when theopt='ADD_VIRTUAL' then do
  1089.       ok=GET_IT('ADDVIRT')
  1090.       foo=get_value('VIRTUAL_FILE')
  1091.       stuff=a_replacestrg(stuff,'$VIRTUAL_FILE',foo,'ALL')
  1092.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1093.       stuff=a_replacestrg(stuff,'$SERVDrive',filespec('d',basedir),'ALL')
  1094.       stuff=a_replacestrg(stuff,'$SERVDir',basedir,'ALL')
  1095.       foo=get_value('CGI_BIN_DIR')
  1096.       stuff=a_replacestrg(stuff,'$cgi_bin_dir',foo,'ALL')
  1097.       foo=get_value('UPLOAD_DIR')
  1098.  
  1099.       stuff=a_replacestrg(stuff,'$upload_dir',foo,'ALL')
  1100.  
  1101.       ok=make_doc(theopt,0,'DIRS')
  1102.  end    
  1103.  
  1104.  when theopt='REMOVE_VIRTUAL' then do
  1105.   ok=GET_IT('REMVIRT')
  1106.     foo=make_virtual('VIRTUAL_FILE')
  1107.     if foo=0 then return 0
  1108.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1109.     foo=get_value('virtual_file')
  1110.     stuff=a_replacestrg(stuff,'$virtual_file',foo,'ALL')
  1111.     stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1112.       stuff=a_replacestrg(stuff,'$SERVDrive',filespec('d',basedir),'ALL')
  1113.     ok=make_doc(theopt,0,'DIRS')
  1114.  
  1115.  end    
  1116.  
  1117.  when theopt='RECORD_OPTION' then do
  1118.       ok=GET_IT('RECORD')
  1119.       tt=strip(upper(get_value('RECORD_OPTION')))
  1120.       fil=get_value('RECORD_ALL_FILE')
  1121.       stuff=a_replacestrg(stuff,'$record_all_file',fil,'ALL')
  1122.       isno='checked' ; isyes=' '; isurl=' '
  1123.       if  tt="YES" | tt="YES_ALL" then do
  1124.          isno=' '; isyes='checked'
  1125.       end  /* Do */
  1126.       if tt='FILE' then do
  1127.           isno=' '; isfile='checked'
  1128.       end  /* Do */
  1129.       stuff=a_replacestrg(stuff,'$isurl',isyes,'ALL')
  1130.       stuff=a_replacestrg(stuff,'$isno',isno,'ALL')
  1131.       stuff=a_replacestrg(stuff,'$isfile',isfile,'ALL')
  1132.  
  1133.       ok=make_doc(theopt,0,'RECORD')
  1134.  
  1135.  end    
  1136.  
  1137.  when theopt='HIT_CACHE_LEN' then do
  1138.       ok=get_it('HITLEN')
  1139.       foo=upper(strip(get_value('HIT_CACHE_LEN')))
  1140.       issmall=' '; isno='checked' ; isbig=' '
  1141.       if foo='FILE' then do
  1142.          isbig='CHECKED' ;isno=' '
  1143.       end  /* Do */
  1144.       if datatype(foo)="NUM" then do
  1145.          if foo>0 then do 
  1146.                 issmall='checked' ;isno=' '
  1147.          end  /* Do */
  1148.       end  /* Do */
  1149.       stuff=a_replacestrg(stuff,'$isno',isno,'ALL')
  1150.       stuff=a_replacestrg(stuff,'$issmall',issmall,'ALL')
  1151.       stuff=a_replacestrg(stuff,'$isbig',isbig,'ALL')
  1152.  
  1153.  
  1154.       ok=make_doc(theopt,0,'RECORD')
  1155.  end
  1156.  
  1157.  when theopt='HIT_OWNER_SUPPRESS' then do
  1158.       ok=get_it('HITOWNER')
  1159.       ok=do_yesno('HIT_OWNER_SUPPRESS','Y')
  1160.       hm=get_value('OWNERS')
  1161.       stuff=a_replacestrg(stuff,'$owners',hm,'ALL')
  1162.       ok=make_doc(theopt,0,'RECORD')
  1163.  end
  1164.  
  1165.  when theopt='WRITE_LOGS' then do
  1166.       ok=get_it('WRITELOG')
  1167.       ok=do_yesno('WRITE_LOGS','Y')
  1168.       stuff=a_replacestrg(stuff,'$workdata',workdata,'ALL')
  1169.  
  1170.       ok=make_doc(theopt,0,'RECORD')
  1171.  end
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  when theopt='SSI_SHTML_ONLY' then do
  1177.       ok=get_it('SHTML')
  1178.       ok=do_yesno('SSI_SHTML_ONLY','Y')
  1179.       hm=get_value('SSI_EXTENSIONS')
  1180.       stuff=a_replacestrg(stuff,'$ssi_extensions',hm,'ALL')
  1181.       ok=make_doc(theopt,0,'SSI')
  1182.  end    
  1183.  
  1184.  when theopt='SSI_CACHE_ON' then do
  1185.       ok=get_it('SSICACHE')
  1186.       ok=do_yesno('SSI_CACHE_ON','Y')
  1187.       hm=get_value('SSI_CACHE_SIZE')
  1188.       stuff=a_replacestrg(stuff,'$ssi_cache_size',hm,'ALL')
  1189.       ok=make_doc(theopt,0,'SSI')
  1190.  end    
  1191.  
  1192.  
  1193.  when theopt='HEADERS' then do
  1194.       ok=get_it('header')
  1195.       hd=strip(get_value('headers'))
  1196.       ft=strip(get_value('footers'))
  1197.       hd=strip(hd,'t','0')
  1198.       ft=strip(ft,'t','0')
  1199.       stuff=a_replacestrg(stuff,'$HD',hd,'ALL')
  1200.       stuff=a_replacestrg(stuff,'$FT',FT,'ALL')
  1201.  
  1202.       ok=make_doc(theopt,0,'SSI')
  1203.  end    
  1204.  
  1205.  when theopt='WEBMASTER' then do
  1206.       ok=get_it('WEBMASTR')
  1207.       p2=get_value('WEBMASTER')
  1208.       p2=a_replacestrg(p2,'<','<','ALL')
  1209.       p2=a_replacestrg(p2,'>','>','ALL')
  1210.       p2=a_replacestrg(p2,'"','"','ALL')
  1211.  
  1212.       stuff=a_replacestrg(stuff,'$webmaster',p2,'ALL')
  1213.       ok=make_doc(theopt,0,'SSI')
  1214.  end    
  1215.  
  1216.  when theopt='ADD_CUSTOM' then do
  1217.       ok=get_it('addcust')
  1218.       foo=get_value('REPSTRGS_FILE')
  1219.       stuff=a_replacestrg(stuff,'$REPLACE_FILE',foo,'ALL')
  1220.       ok=make_doc(theopt,0,'SSI')
  1221.   end 
  1222.  
  1223.  
  1224.  when theopt='REMOVE_CUSTOM' then do
  1225.       ok=get_it('remcust')
  1226.  
  1227.     foo=make_custom('repstrgs_file')
  1228.      if foo=0 then return 0
  1229.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1230.     ok=make_doc(theopt,0,'SSI')
  1231.  
  1232.  end 
  1233.  
  1234.  when theopt='ADD_REDIRECT' then do
  1235.       ok=GET_IT('ADDALIAS')
  1236.       foo=get_value('ALIAS_FILE')
  1237.       stuff=a_replacestrg(stuff,'$ALIAS_FILE',foo,'ALL')
  1238.       ok=make_doc(theopt,0,'DIR')
  1239.  end 
  1240.  
  1241.  when theopt='REMOVE_REDIRECT' then do
  1242.     ok=GET_IT('REMAlias')
  1243.     foo=make_alias('alias_file')
  1244.     if foo=0 then return 0
  1245.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1246.     foo=get_value('alias_file')
  1247.     stuff=a_replacestrg(stuff,'$alias_file',foo,'ALL')
  1248.     ok=make_doc(theopt,0,'DIR')
  1249.  end
  1250.  
  1251.  when theopt='NO_SS' then do
  1252.      ok=GET_IT('noss')
  1253.      ok=do_yesno('NO_INCLUDE','N')
  1254.  
  1255.       tssp=get_value('NO_PROCESSING')
  1256.       tint=get_value('NO_INTERPRET_code')
  1257.  
  1258.       okssp=' '; nossp=' ' ; noint=' '
  1259.       if tssp=0 & tint=0 then do
  1260.          okssp='CHECKED'
  1261.       end  /* Do */
  1262.       else do
  1263.          if tint=1 & tssp=0 then
  1264.             noint='checked'
  1265.          else
  1266.             nossp='checked'
  1267.       end  /* Do */
  1268.       stuff=a_replacestrg(stuff,'$NO_SSP_INT',noint,'ALL')   /* careful, kind of confusing! */
  1269.       stuff=a_replacestrg(stuff,'$NO_SSP_YES',nossp,'ALL')
  1270.       stuff=a_replacestrg(stuff,'$NO_SSP_NO',okssp,'ALL')
  1271.       ok=make_doc(theopt,0,'MISC')
  1272.  
  1273.  end    
  1274.  when theopt='FIX_EXPIRE' then do
  1275.       ok=get_it('fixexpir')
  1276.       foo=get_value('FIX_EXPIRE')
  1277.       isyes=' ' ; isno='checked '
  1278.       if datatype(foo)="NUM" then do
  1279.          if foo>0 then do 
  1280.                 isyes='checked' ; isno=' '
  1281.          end  /* Do */
  1282.       end  /* Do */
  1283.       stuff=a_replacestrg(stuff,'$ISYES',isyes,'ALL')
  1284.       stuff=a_replacestrg(stuff,'$ISNO',isno,'ALL')
  1285.  
  1286.       ok=make_doc(theopt,0,'MISC')
  1287.  end    
  1288.  
  1289.  when theopt='SMTP_GATEWAY' then do
  1290.       ok=get_it('SMTP')
  1291.       hm=get_value('SMTP_GATEWAY')
  1292.       stuff=a_replacestrg(stuff,'$SMTP_GATEWAY',hm,'ALL')
  1293.       ok=make_doc(theopt,0,'MISC')
  1294.  
  1295.  end  
  1296.  
  1297. otherwise do
  1298.   'STRING NO SUCH Option= ' theopt
  1299.    ok='200 25'
  1300. end
  1301.  
  1302. end  /* select */
  1303.  
  1304. return ok
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310. /********************************************/
  1311. responsecf:procedure
  1312.  parse arg  request,atext,stuff
  1313.  
  1314.  
  1315.   select
  1316.     when request='badreq'   then use='400 Bad request syntax'
  1317.     when request='notfound' then use='404 Not found'
  1318.     when request='forbid'   then use='403 Forbidden'
  1319.     when request='unauth'   then use='401 Unauthorized'
  1320.     when request='notallowed' then use='405 Method not allowed'
  1321.     when request='notimplemented' then use='501 Not implemented'
  1322.     otherwise do
  1323.         use='406 Not acceptable'
  1324.         call pmprintf('weird response '|| request||' '|| message)
  1325.       end
  1326.     end  /* Add others to this list as needed */
  1327.  
  1328.  
  1329.   /* Now set the response and build the response file */
  1330.   'RESPONSE HTTP/1.0' use     /* Set HTTP response line */
  1331.   parse var use code text
  1332.   if request='notallowed' then do
  1333.      'HEADER ADD Allow:HEAD '
  1334.   end
  1335.  
  1336.   call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1337.   call lineout tempfile, "<html><head><title>"text"</title></head>"
  1338.   call lineout tempfile, "<body><h2>Sorry...</h2>"
  1339.   select
  1340.     when request='unauth' then do
  1341.         'header add WWW-Authenticate: Basic Realm=<'atext'>'  /* challenge */
  1342.        if stuff=' ' then
  1343.          call lineout tempfile,' You are not authorized to visit this area of the bulletin board '
  1344.        else
  1345.          call lineout tempfile,' You must supply a Username if you wish to use this Configurator '
  1346.     end
  1347.     when request='notfound' then
  1348.       call lineout tempfile,' File is unavailable: ' stuff
  1349.     when requeset='forbidden' then
  1350.       call lineout tempfile,' Configurator is unavailable.'
  1351.     otherwise
  1352.        call lineout tempfile,' Request denied: ' stuff
  1353.   end
  1354.   call lineout tempfile, "</body></html>"
  1355.   call lineout tempfile  /* close */
  1356.  
  1357.   'FILE ERASE TYPE text/html NAME ' tempfile
  1358.   return 0
  1359.  
  1360.  
  1361. end   
  1362.  
  1363. return ' '
  1364.  
  1365.  
  1366.  
  1367.  
  1368. /******************/
  1369. /* READ appropriate file from config_dir directory. Return as a big string */
  1370. get_it:procedure expose thedir stuff verbose
  1371. parse arg thefile
  1372.  
  1373. stuff=' '
  1374. afile=thedir||'\'||thefile||'.CNF'
  1375. aa=stream(afile,'c','query exists')
  1376. if aa=' ' then do
  1377.   if verbose>1 then say " Missing configuration file: " afile
  1378.    return 0
  1379. end
  1380.  
  1381. stuff=charin(aa,1,chars(aa))
  1382. stuff=strip(stuff,'t','1a'x)
  1383.  
  1384.  
  1385. aa=stream(aa,'c','close')
  1386. return 1
  1387.  
  1388. /******************/
  1389. /* replace isyes and isno in stuff */
  1390. do_yesno:procedure expose stuff servername host_nickname enmadd
  1391. parse upper arg param,def, yeses,nos
  1392. if yeses=' ' then yeses='Y YES 1'
  1393. if nos=' '  then nos='N NO 0 '
  1394. got1=0
  1395. isit=upper(get_value(param))
  1396. agin:
  1397. if  wordpos(isit,yeses)>0 then do
  1398.     isyes='CHECKED' ; isno=' ' ;got1=1
  1399. end
  1400. if wordpos(isit,nos)>0 then do
  1401.      isyes=' ' ; isno='CHECKED';got1=1
  1402. end
  1403. if got1=0 then do
  1404.    got1=1
  1405.    isit=def
  1406.    signal agin
  1407. end  /* Do */
  1408.  
  1409. stuff=a_replacestrg(stuff,'$ISYES',isyes,'ALL')
  1410. stuff=a_replacestrg(stuff,'$ISNO',isno,'ALL')
  1411.  
  1412. return 1
  1413.  
  1414.  
  1415. /******************/
  1416. /* take modified template, make into legit html document, and return */
  1417. make_doc:procedure expose stuff tempfile servername host_nickname usecolor
  1418. parse arg theopt,NOHOST,jumpto
  1419. crlf='0d0a'x
  1420. cc='<br><a href="/config0.htm#'jumpto'"><B>CANCEL</B> </a><br>'||crlf
  1421. cc=cc||'<A NAME="info"> <br> <!-- jump here for help --></A>'||crlf
  1422.  
  1423. stuff=a_replacestrg(stuff,'$CANCEL',cc,'ALL')
  1424.  
  1425. v1='<!doctype html public "-//IETF//DTD HTML 2.0//EN">'||crlf
  1426. v1=v1||"<html><head><title> SRE-Filter configurator: "theopt"</title></head>"||crlf
  1427. v1=v1||'<BODY bgcolor="#'||usecolor||'">'||crlf
  1428. j1='<A HREF="#info">Notes, hints, and examples</A> '||crlf
  1429. if host_nickname<>' ' & NOHOST<>1 then do
  1430.    j1=j1||'     ..... Modifying parameters for the <b>' host_nickname '</b> <em> host</em>'||crlf
  1431. end  /* Do */
  1432. j1=j1||'<br> <A NAME="setparam">   </A>'||crlf
  1433.  
  1434.  
  1435.  
  1436. v1=v1||j1||stuff||crlf
  1437. j2='<br><A HREF="#setparam">Return to parameter modification screen</A>'||crlf
  1438. v1=v1||j2||'<hr>'||crlf
  1439. v1=v1||'<a href="/config0.htm">Cancel and return to Simple Configurator Introduction </a>'||crlf
  1440. v1=v1||'<p><em> From server at: '||servername||'</em>'||crlf
  1441. v1=v1||'</body></html>'
  1442. 'VAR TYPE text/html NAME v1 '
  1443. return '200 '||length(v1)
  1444.  
  1445. /* ----------- */                                                        
  1446. /* get environment value, possibly host specific
  1447. hname=0 -- do not look under hostname
  1448. hname=1 -- do not look under default
  1449.  */                      
  1450. /* ------------ */                                                       
  1451. get_value: procedure expose enmadd host_nickname                          
  1452. parse upper arg vname,hname0
  1453. if hname0=0 then 
  1454.         hname=' '
  1455. else                                                    
  1456.     hname=strip(host_nickname)                          
  1457.  
  1458. vname=strip(vname) ;
  1459. if hname<>' ' then do
  1460.    booger=strip(enmadd||vname||'.'||hname)
  1461.    aval=value(booger,,'os2environment')
  1462.    if aval<>' ' | hname0=1 Then
  1463.         return aval                                                      
  1464. end                                                                      
  1465. aval=value(enmadd||vname,,'os2environment')                              
  1466. return aval                                                              
  1467.  
  1468.  
  1469.  
  1470.  
  1471. /**************************/
  1472. /* check for legitimacy of the client */
  1473. okay_client:              /* subroutine. set the notokay variable */
  1474.  
  1475. rstatus=' '
  1476. who2=extract('CLIENTADDR')
  1477. saddr2=extract('SERVERADDR')
  1478.  
  1479. select
  1480.    when checkit=1 then do
  1481. /* only if user = serveraddress !!! */
  1482.      if who2<>saddr2 then do  /* auto entry if sitting at server and checkit=1 */
  1483.  
  1484.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  1485.         call lineout tempfile, "<html><head><title>SREFILTER ERROR </title>"
  1486.         call lineout tempfile, "</head><body>"
  1487.  
  1488.         call lineout tempfile,' <strong> The Simple Configurator can not be run remotely.</strong> '
  1489.         call lineout tempfile,' </body> </html> '
  1490.         call lineout tempfile
  1491.         'FILE ERASE TYPE text/html NAME' tempfile
  1492.          notokay=1
  1493.          return 1
  1494.      end
  1495.    end
  1496.    otherwise do         /* checkit=0 */
  1497.       if wordpos('SUPERUSER',upper(privset))=0 then do
  1498.           aa=responsecf('unauth','configure','SUPERUSER privileges required for remote configuration')
  1499.          rstatus='401 0'
  1500.          notokay=1
  1501.          return 1
  1502.       end
  1503.    end
  1504. end
  1505. notokay=0
  1506. return 0
  1507.  
  1508. /************************/
  1509. /* remove entries from a paramter file */
  1510. change_file:procedure expose host_nickname enmadd tempfile mess2
  1511.  
  1512. parse arg thingie, newval,remlist,noupdate,nocvt,nohost
  1513. newval0=newval
  1514. lookfor=get_value(thingie)   /* the file to change */
  1515. if lookfor=' ' then return " Could not find: " thingie
  1516. foo=fileread(lookfor,dalines,,'E')
  1517. if dalines.0=0 then return 'Could not read:'||lookfor
  1518.  
  1519. /* scan through, looking for parameters that match:
  1520. if in remlist, remove. If = newval, remove and replace.
  1521. If no match, and newval<>' ', put newval at the end
  1522. */
  1523.  
  1524. remlist=strip(upper(translate(remlist,'/','\')))
  1525. remlist=strip(remlist,,'/')
  1526. newval=strip(upper(translate(newval,'/','\')))
  1527. newval=strip(newval,,'/')
  1528.  
  1529.  
  1530. inew=0
  1531. ninh=0
  1532. nkill=0
  1533. do mm=1 to dalines.0
  1534.    aline=upper(strip(dalines.mm))
  1535.    if abbrev(aline,';')=1 | aline=' ' then do /*retain comments */
  1536.       inew=inew+1
  1537.       newlines.inew=dalines.mm
  1538.       iterate
  1539.    end
  1540.    if nohost<>1 then do
  1541.      if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//'  then do   /* host specific, does it match ? */
  1542.          parse var aline ahost '//' aline
  1543.          if strip(ahost)<>host_nickname then do /* no match, retain */
  1544.             inew=inew+1
  1545.             newlines.inew=dalines.mm
  1546.             iterate
  1547.          end  /* Do */
  1548.       end  /* Do */
  1549.       else do   /* generic== skip if host-Nickname is active */
  1550.        if host_nickname<>' ' then do
  1551.             inew=inew+1
  1552.             newlines.inew=dalines.mm
  1553.             iterate
  1554.        end  /* Do */
  1555.      end
  1556.    end  /* nohost -- so don't worry about host stuff */
  1557.  
  1558. /* if here, generic or host-matches. Is it in remlist */
  1559.    if (nohost<>1) & , 
  1560.        (wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//')  then   /* host specific, does it match ? */
  1561.           parse var aline . '//' aentry .
  1562.    else
  1563.           parse var aline aentry .
  1564.  
  1565.    if remlist<>' ' then do
  1566.      use1=upper(strip(word(aentry,1)))
  1567.      aentry=strip(translate(aentry,'/','\'),,'/')
  1568.      if wordpos(aentry,remlist)>0 then do    /* skip this one */
  1569.         nkill=nkill+1
  1570.         iterate
  1571.       end  /* Do */
  1572.    end  /* Do */
  1573.  
  1574. /*is it the newval? */
  1575.    newval1=strip(word(newval,1))
  1576.  
  1577.    if newval1=aentry then iterate /* don't copy -- will redo */
  1578.  
  1579.    inew=inew+1                  /* keep */
  1580.    newlines.inew=dalines.mm
  1581. end
  1582.  
  1583. if newval<>' ' then do /* add the new one */
  1584.    inew=inew+1
  1585.    newval=newval0
  1586.    if abbrev(strip(newval0),'*')=1 then
  1587.        newval='/'||strip(newval0)
  1588.    if nocvt=1 then newval=translate(newval,'\','/')
  1589.    if host_nickname<>' ' then
  1590.        newlines.inew=host_nickname||' // '||newval
  1591.    else
  1592.        newlines.inew=newval
  1593. end
  1594.  
  1595. if noupdate<>1 then do
  1596.    bakfile=lookfor               /* create a .bak file */
  1597.    foo=lastpos('.',bakfile)
  1598.    if foo=0  then
  1599.       bakfile=bakfile||'.bak'
  1600.    else
  1601.       bakfile=delstr(bakfile,foo)||'.bak'
  1602.    wow=doscopy(STRIP(LOOKFOR),STRIP(bakfile),'R')
  1603.    if wow<>0 then do
  1604.       say " ERROR: backup copy could not be made, error code  " wow
  1605.       return 'Backup copy could not be made'
  1606.   end  /* Do */
  1607. end
  1608. NEWLINES.0=INEW
  1609. /* now write new results */
  1610. foo=filewrite(lookfor,newlines,'R')
  1611.  
  1612. if foo=0 then  return 'Could not save parameters file '
  1613.  
  1614. mess2=' Number entries deleted: '||nkill
  1615. return 1  /* success */
  1616.  
  1617.  
  1618.  
  1619. /************************/
  1620. /* extract entries from a paramter file */
  1621. make_users:procedure expose host_nickname enmadd tempfile stuff2
  1622. parse arg thingie
  1623. crlf='0d0a'x
  1624. afile=get_value(thingie)
  1625. foo=fileread(afile,dalines,,'E')
  1626. if dalines.0=0 then do
  1627.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1628.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  1629.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1630.     call lineout tempfile,' <b>Error</b>: could not process USERNAME file: ' afile
  1631.     call lineout tempfile, "</body></html>"
  1632.     call lineout tempfile  /* close */
  1633.    'FILE ERASE TYPE text/html NAME ' tempfile
  1634.    return 0
  1635. end  /* Do */
  1636.  
  1637. ngot=0
  1638. do mm=1 to dalines.0
  1639.     aline=upper(strip(dalines.mm))
  1640.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  1641.     if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//'  then do   /* host specific, does it match ? */
  1642.          parse var aline ahost '//' aline
  1643.          if strip(ahost)<>host_nickname then iterate
  1644.     end  /* Do */
  1645.     else do   /* generic== skip if host-Nickname is active */
  1646.        if host_nickname<>' ' then iterate
  1647.    end
  1648. /* got a match, extract username */
  1649.    ngot=ngot+1
  1650.    parse var aline users.ngot .
  1651. end /* do */
  1652.  
  1653. if ngot=0 then do
  1654.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1655.     call lineout tempfile, "<html><head><title>No users in username database</title></head>"
  1656.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1657.     if host_nickname<>' ' then
  1658.        call lineout tempfile,' <b>There are no user entries (for the ' host_nickname ' Host) in the user database: ' afile
  1659.     else
  1660.        call lineout tempfile,' <b>There are no user entries  in the user database: ' afile
  1661.  
  1662.     call lineout tempfile, "</body></html>"
  1663.     call lineout tempfile  /* close */
  1664.    'FILE ERASE TYPE text/html NAME ' tempfile
  1665.    return 0
  1666. end  /* Do */
  1667.  
  1668. /* now create a  list */
  1669. aa.1='<h2> Select Entries to Remove </h2> '
  1670. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1671. aa.3='<ol> '
  1672. do mm=1 to ngot
  1673.   fee=3+mm
  1674.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b>'
  1675. end /* do */
  1676.  
  1677. fee=3+ngot+1
  1678. aa.fee='</ol>'
  1679. fee=fee+1
  1680. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  1681.  
  1682. stuff2=aa.1
  1683. do mm=2 to fee
  1684.   stuff2=stuff2||crlf||aa.mm
  1685. end
  1686. return 1
  1687.  
  1688.  
  1689. /************************/
  1690. /* extract entries from a paramter file */
  1691. make_access:procedure expose host_nickname enmadd tempfile stuff2
  1692. parse arg thingie,getdef
  1693.  
  1694. crlf='0d0a'x
  1695. afile=get_value(thingie)
  1696. foo=fileread(afile,dalines,,'E')
  1697. if dalines.0=0 then do
  1698.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1699.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  1700.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1701.     call lineout tempfile,' <b>Error</b>: could not process Access Control file: ' afile
  1702.     call lineout tempfile, "</body></html>"
  1703.     call lineout tempfile  /* close */
  1704.    'FILE ERASE TYPE text/html NAME ' tempfile
  1705.    return 0
  1706. end  /* Do */
  1707.  
  1708. ngot=0
  1709. do mm=1 to dalines.0
  1710.     aline=upper(strip(dalines.mm))
  1711.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  1712.     if abbrev(aline,'!')=1  then iterate /* don't do realm entries */
  1713.     if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  1714.          parse var aline ahost '//' aline
  1715.          if strip(ahost)<>host_nickname then iterate
  1716.     end  /* Do */
  1717.     else do   /* generic== skip if host-Nickname is active */
  1718.        if host_nickname<>' ' then iterate
  1719.    end
  1720. /* got a match, extract access control entyr */
  1721.    parse var aline pepsi pop ; pepsi=strip(pepsi)
  1722.    parse var pop privs ',' .
  1723.    if pepsi='*' | pepsi=='/*' | pepsi='\*' then do
  1724.        if getdef=1  then do   /* looking for default, are we? */
  1725.            stuff2=privs
  1726.            return strip(stuff2)
  1727.        end  /* Do */
  1728.        iterate          /* else, ignore */
  1729.    end  /* Do */
  1730.    ngot=ngot+1
  1731.    users.ngot=pepsi
  1732.   privs=strip(space(privs))
  1733.    if length(privs)>50 then privs=left(privs,45)||' ...'
  1734.    users.ngot.2=privs
  1735. end /* do */
  1736.  
  1737. if getdef=1 then do
  1738.  stuff2=' '
  1739.  return 1
  1740. end
  1741.  
  1742. if ngot=0 then do
  1743.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1744.     call lineout tempfile, "<html><head><title>No entries in the access control </title></head>"
  1745.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1746.     if host_nickname<>' ' then
  1747.        call lineout tempfile,' <b>There are no entries (for the ' host_nickname ' Host) in the access control file: ' afile
  1748.     else
  1749.        call lineout tempfile,' <b>There are no entries  in the access control file: ' afile
  1750.     call lineout tempfile, "</body></html>"
  1751.     call lineout tempfile  /* close */
  1752.    'FILE ERASE TYPE text/html NAME ' tempfile
  1753.    return 0
  1754. end  /* Do */
  1755.  
  1756. /* now create a  list */
  1757. aa.1='<h2> Select Entries to Remove </h2> '
  1758. aa.2='<em>Unchecked entries will be retained</em> <code>(first 45 characters of privilege list are displayed)</code> <br>'
  1759. aa.3='<ol> '
  1760. do mm=1 to ngot
  1761.   fee=3+mm
  1762.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> <code>(privs= 'users.mm.2 '</code>'
  1763. end /* do */
  1764. fee=3+ngot+1
  1765. aa.fee='</ol>'
  1766. fee=fee+1
  1767. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  1768.  
  1769. stuff2=aa.1
  1770. do mm=2 to fee
  1771.   stuff2=stuff2||crlf||aa.mm
  1772. end
  1773. return 1
  1774.  
  1775.  
  1776.  
  1777. /************************/
  1778. /* extract entries from a initfilt.80 parameter file */
  1779. make_inhouseips:procedure expose host_nickname enmadd tempfile stuff2
  1780. crlf='0d0a'x
  1781.  
  1782. parse arg thingie
  1783. crlf='0d0a'x
  1784. afile=get_value(thingie)
  1785. foo=fileread(afile,dalines,,'E')
  1786.  
  1787. if dalines.0=0 then do
  1788.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1789.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  1790.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1791.     call lineout tempfile,' <b>Error</b>: could not process initialization file: ' afile
  1792.     call lineout tempfile, "</body></html>"
  1793.     call lineout tempfile  /* close */
  1794.    'FILE ERASE TYPE text/html NAME ' tempfile
  1795.    return 0
  1796. end  /* Do */
  1797.  
  1798. /* read initfilt.80 file, look for inhousesips entries */
  1799. igot=0
  1800. do mm=1 to dalines.0
  1801.    aline=upper(strip(dalines.mm))
  1802.    if aline=' ' | abbrev(aline,';')=1 then iterate
  1803.    if abbrev(aline,'INHOUSEIPS.')=0 then iterate
  1804.    parse var aline p1 '=' p2 ; p2=strip(p2)
  1805.    p2=strip(p2,,"'"); p2=strip(p2,,'"') ;p2=strip(p2)
  1806.    if p2=' ' | p2=0 then iterate
  1807.    p1=translate(p1,' ','.')
  1808.    if words(p1)=1 then iterate  /* error, ignore */
  1809.    if words(p1)=2 & host_nickname=' ' then do
  1810.         igot=igot+1
  1811.         gotinh.igot=word(strip(p2),1)
  1812.    end  /* Do */
  1813.    if words(p1)=3 then do            /* 3rd is host nickmane */
  1814.         if strip(word(p1,3))=host_nickname then do
  1815.             igot=igot+1
  1816.             gotinh.igot=word(strip(p2),1)
  1817.         end  /* Do */
  1818.    end /* do */
  1819. end /* do */
  1820.  
  1821. if igot=0 then do
  1822.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1823.     call lineout tempfile, "<html><head><title>No In-House Entries</title></head>"
  1824.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1825.     if host_nickname<>' ' then
  1826.        call lineout tempfile,' <b>There are no In-house entries (for the ' host_nickname ' Host '
  1827.     else
  1828.        call lineout tempfile,' <b>There are no In-house entries'
  1829.     call lineout tempfile, "</body></html>"
  1830.     call lineout tempfile  /* close */
  1831.    'FILE ERASE TYPE text/html NAME ' tempfile
  1832.    return 0
  1833. end  /* Do */
  1834.  
  1835.  
  1836. /* now create a  list */
  1837. aa.1='<h2> Select Entries to Remove </h2> '
  1838. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1839. aa.3='<ol> '
  1840. do mm=1 to igot
  1841.   fee=3+mm
  1842.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||gotinh.mm||'" > <b> '||gotinh.mm||'</b>'
  1843. end /* do */
  1844. fee=3+igot+1
  1845. aa.fee='</ol>'
  1846. fee=fee+1
  1847. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1848.  
  1849. stuff2=aa.1
  1850. do mm=2 to fee
  1851.   stuff2=stuff2||crlf||aa.mm
  1852. end
  1853. return 1
  1854.  
  1855.  
  1856.  
  1857.  
  1858. /************************/
  1859. /* extract entries from a initfilt.80 parameter file */
  1860. make_puburls:procedure expose host_nickname enmadd tempfile stuff2
  1861. crlf='0d0a'x
  1862.  
  1863. parse arg thingie
  1864. crlf='0d0a'x
  1865. afile=get_value(thingie)
  1866. foo=fileread(afile,dalines,,'E')
  1867.  
  1868. if dalines.0=0 then do
  1869.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1870.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  1871.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1872.     call lineout tempfile,' <b>Error</b>: could not process initialization file: ' afile
  1873.     call lineout tempfile, "</body></html>"
  1874.     call lineout tempfile  /* close */
  1875.    'FILE ERASE TYPE text/html NAME ' tempfile
  1876.    return 0
  1877. end  /* Do */
  1878.  
  1879. /* read initfilt.80 file, look for public_urls. entries */
  1880. igot=0
  1881. do mm=1 to dalines.0
  1882.    aline=upper(strip(dalines.mm))
  1883.    if aline=' ' | abbrev(aline,';')=1 then iterate
  1884.    if abbrev(aline,'PUBLIC_URLS.')=0 then iterate
  1885.    parse var aline p1 '=' p2 ; p2=strip(p2)
  1886.    p2=strip(p2,,"'"); p2=strip(p2,,'"') ;p2=strip(p2)
  1887.    if p2=' ' | p2=0 then iterate
  1888.    p1=translate(p1,' ','.')
  1889.    if words(p1)=1 then iterate  /* error, ignore */
  1890.    if words(p1)=2 & host_nickname=' ' then do
  1891.         igot=igot+1
  1892.         gotinh.igot=word(strip(p2),1)
  1893.    end  /* Do */
  1894.    if words(p1)=3 then do            /* 3rd is host nickmane */
  1895.         if strip(word(p1,3))=host_nickname then do
  1896.             igot=igot+1
  1897.             gotinh.igot=word(strip(p2),1)
  1898.         end  /* Do */
  1899.    end /* do */
  1900. end /* do */
  1901.  
  1902. if igot=0 then do
  1903.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1904.     call lineout tempfile, "<html><head><title>No PUBLIC area identifiers</title></head>"
  1905.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1906.     if host_nickname<>' ' then
  1907.        call lineout tempfile,' <b>There are no PUBLIC area  PUBLIC area identifiters (for the ' host_nickname ' Host '
  1908.     else
  1909.        call lineout tempfile,' <b>There are no PUBLIC area identifiers '
  1910.     call lineout tempfile, "</body></html>"
  1911.     call lineout tempfile  /* close */
  1912.    'FILE ERASE TYPE text/html NAME ' tempfile
  1913.    return 0
  1914. end  /* Do */
  1915.  
  1916.  
  1917. /* now create a  list */
  1918. aa.1='<h2> Select Entries to Remove </h2> '
  1919. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1920. aa.3='<ol> '
  1921. do mm=1 to igot
  1922.   fee=3+mm
  1923.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||gotinh.mm||'" > <b> '||gotinh.mm||'</b>'
  1924. end /* do */
  1925. fee=3+igot+1
  1926. aa.fee='</ol>'
  1927. fee=fee+1
  1928. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1929.  
  1930. stuff2=aa.1
  1931. do mm=2 to fee
  1932.   stuff2=stuff2||crlf||aa.mm
  1933. end
  1934. return 1
  1935.  
  1936.  
  1937.  
  1938. /************************/
  1939. /* extract entries from a initfilt.80 parameter file */
  1940. make_hosts:procedure expose host_nickname enmadd tempfile stuff2
  1941. crlf='0d0a'x
  1942.  
  1943. parse arg thingie
  1944. crlf='0d0a'x
  1945. afile=get_value(thingie)
  1946. foo=fileread(afile,dalines,,'E')
  1947.  
  1948. if dalines.0=0 then do
  1949.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1950.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  1951.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1952.     call lineout tempfile,' <b>Error</b>: could not process initialization file: ' afile
  1953.     call lineout tempfile, "</body></html>"
  1954.     call lineout tempfile  /* close */
  1955.    'FILE ERASE TYPE text/html NAME ' tempfile
  1956.    return 0
  1957. end  /* Do */
  1958.  
  1959. /* read initfilt.80 file, look for host entries */
  1960. igot=0
  1961. do mm=1 to dalines.0
  1962.    aline=upper(strip(dalines.mm))
  1963.    if aline=' ' | abbrev(aline,';')=1 then iterate
  1964.    if abbrev(aline,'HOSTS.')=0 then iterate
  1965.    parse var aline p1 '=' p2 ; 
  1966.     p2=translate(p2,' ',"'"||'"') ; p2=strip(p2)
  1967.    if p2=0 then iterate
  1968.    parse var p2 anip ',' anick ',' . 
  1969.    igot=igot+1
  1970.    ahosts.igot=strip(upper(anip))
  1971.    ahosts.igot.2=strip(upper(anick))
  1972.  
  1973. end /* do */
  1974.  
  1975. if igot=0 then do
  1976.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1977.     call lineout tempfile, "<html><head><title>No HOST definitions</title></head>"
  1978.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1979.     call lineout tempfile,' <b>There are no host definitions'
  1980.     call lineout tempfile, "</body></html>"
  1981.     call lineout tempfile  /* close */
  1982.    'FILE ERASE TYPE text/html NAME ' tempfile
  1983.    return 0
  1984. end  /* Do */
  1985.  
  1986.  
  1987. /* now create a  list */
  1988. aa.1='<h2> Select Entries to Remove </h2> '
  1989. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1990. aa.3='<ol> '
  1991. do mm=1 to igot
  1992.   fee=3+mm
  1993.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||ahosts.mm||'" > '||ahosts.mm||'(with host nickname of <b> ' ahosts.mm.2 '</b>)'
  1994. end /* do */
  1995. fee=3+igot+1
  1996. aa.fee='</ol>'
  1997. fee=fee+1
  1998. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1999.  
  2000. stuff2=aa.1
  2001. do mm=2 to fee
  2002.   stuff2=stuff2||crlf||aa.mm
  2003. end
  2004. return 1
  2005.  
  2006.  
  2007.  
  2008. /************************/
  2009. /* extract entries from a virtual dir  file */
  2010. make_virtual:procedure expose host_nickname enmadd tempfile stuff2
  2011. parse arg thingie
  2012. crlf='0d0a'x
  2013. afile=get_value(thingie)
  2014. foo=fileread(afile,dalines,,'E')
  2015. if dalines.0=0 then do
  2016.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2017.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  2018.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2019.     call lineout tempfile,' <b>Error</b>: could not process virtual directory file: ' afile
  2020.     call lineout tempfile, "</body></html>"
  2021.     call lineout tempfile  /* close */
  2022.    'FILE ERASE TYPE text/html NAME ' tempfile
  2023.    return 0
  2024. end  /* Do */
  2025.  
  2026. ngot=0
  2027. do mm=1 to dalines.0
  2028.     aline=upper(strip(dalines.mm))
  2029.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  2030.     if wordpos('//',aline)=2 | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  2031.          parse var aline ahost '//' aline
  2032.          if strip(ahost)<>host_nickname then iterate
  2033.     end  /* Do */
  2034.     else do   /* generic== skip if host-Nickname is active */
  2035.        if host_nickname<>' ' then iterate
  2036.    end
  2037. /* got a match, extract virtual dir */
  2038.    ngot=ngot+1
  2039.    parse var aline wow thedir
  2040.    users.ngot=strip(translate(wow,'/','\'),,'/')||'/'
  2041.    thedir=strip(translate(thedir,' ','*'))
  2042.    users.ngot.2=thedir
  2043. end /* do */
  2044.  
  2045. if ngot=0 then do
  2046.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2047.     call lineout tempfile, "<html><head><title>No entries in virtual directory list</title></head>"
  2048.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2049.     if host_nickname<>' ' then
  2050.     call lineout tempfile,' <b>There are no virtual directory entries (for the ' host_nickname ' Host) in: ' afile
  2051.     else
  2052.     call lineout tempfile,' <b>There are no virtual directory entries in: ' afile
  2053.  
  2054.     call lineout tempfile, "</body></html>"
  2055.     call lineout tempfile  /* close */
  2056.    'FILE ERASE TYPE text/html NAME ' tempfile
  2057.    return 0
  2058. end  /* Do */
  2059.  
  2060. /* now create a  list */
  2061. aa.1='<h2> Select Entries to Remove </h2> '
  2062. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  2063. aa.3='<ol> '
  2064. do mm=1 to ngot
  2065.   fee=3+mm
  2066.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b>      (... maps to:<tt> ' users.mm.2 '</tt>)'
  2067. end /* do */
  2068. fee=3+ngot+1
  2069. aa.fee='</ol>'
  2070. fee=fee+1
  2071. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2072.  
  2073. stuff2=aa.1
  2074. do mm=2 to fee
  2075.   stuff2=stuff2||crlf||aa.mm
  2076. end
  2077. return 1
  2078.  
  2079.  
  2080. /************************/
  2081. /* extract entries from an alias file */
  2082. make_alias:procedure expose host_nickname enmadd tempfile stuff2
  2083. parse arg thingie
  2084. crlf='0d0a'x
  2085. afile=get_value(thingie)
  2086. foo=fileread(afile,dalines,,'E')
  2087. if dalines.0=0 then do
  2088.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2089.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  2090.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2091.     call lineout tempfile,' <b>Error</b>: could not process redirection aliases file: ' afile
  2092.     call lineout tempfile, "</body></html>"
  2093.     call lineout tempfile  /* close */
  2094.    'FILE ERASE TYPE text/html NAME ' tempfile
  2095.    return 0
  2096. end  /* Do */
  2097. ngot=0
  2098. do mm=1 to dalines.0
  2099.     aline=upper(strip(dalines.mm))
  2100.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  2101.     if wordpos('//',aline)=2 | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  2102.          parse var aline ahost '//' aline
  2103.          if strip(ahost)<>host_nickname then iterate
  2104.     end  /* Do */
  2105.     else do   /* generic== skip if host-Nickname is active */
  2106.        if host_nickname<>' ' then iterate
  2107.    end
  2108. /* got a match, extract alias */
  2109.    parse var aline wow whereto
  2110.    foo2=upper(whereto)
  2111.    jump=pos('HTTP://',foo2)+ pos('!MOVED',foo2) + pos('!TEMP',foo2)
  2112.    if jump=0 then iterate /* remote redirection only */
  2113.  
  2114.    ngot=ngot+1
  2115.    wow=strip(wow); if right(wow,1)<>'*' then
  2116.        users.ngot=strip(translate(wow,'/','\'),,'/')||'/'
  2117.    else
  2118.         users.ngot=wow
  2119.     whereto=strip(whereto)
  2120.    if length(whereto)>60 then whereto=left(whereto,55)||' ...'
  2121.    users.ngot.2=whereto
  2122.  
  2123. end /* do */
  2124.  
  2125. if ngot=0 then do
  2126.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2127.     call lineout tempfile, "<html><head><title>No entries in redirection alias list</title></head>"
  2128.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2129.     if host_nickname<>' ' then
  2130.       call lineout tempfile,' <b>There are no redirection aliases entries (for the ' host_nickname' Host) in: ' afile
  2131.     else
  2132.       call lineout tempfile,' <b>There are no redirection aliases entries in: ' afile
  2133.     call lineout tempfile, "</body></html>"
  2134.     call lineout tempfile  /* close */
  2135.    'FILE ERASE TYPE text/html NAME ' tempfile
  2136.    return 0
  2137. end  /* Do */
  2138.  
  2139. /* now create a  list */
  2140. aa.1='<h2> Select Entries to Remove </h2> '
  2141. aa.2='<em>Unchecked entries will be retained</em> (<code> The first 55 characters are displayed. </code>) <br>'
  2142. aa.3='<ol> '
  2143. do mm=1 to ngot
  2144.   jj=' (<em> redirecting to:' users.mm.2 '</em>)'
  2145.   fee=3+mm
  2146.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> (redirect to:<tt> ' users.mm.2 '</tt>'
  2147. end /* do */
  2148. fee=3+ngot+1
  2149. aa.fee='</ol>'
  2150. fee=fee+1
  2151. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2152.  
  2153. stuff2=aa.1
  2154. do mm=2 to fee
  2155.   stuff2=stuff2||crlf||aa.mm
  2156. end
  2157. return 1
  2158.  
  2159.  
  2160.  
  2161.  
  2162. /************************/
  2163. /* extract entries from a replacement strings file */
  2164. make_custom:procedure expose host_nickname enmadd tempfile stuff2
  2165. parse arg thingie
  2166. crlf='0d0a'x
  2167. afile=get_value(thingie)
  2168. foo=fileread(afile,dalines,,'E')
  2169. if dalines.0=0 then do
  2170.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2171.     call lineout tempfile, "<html><head><title>Problem with SRE-Filter configurator</title></head>"
  2172.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2173.     call lineout tempfile,' <b>Error</b>: could not process replacement strings file: ' afile
  2174.     call lineout tempfile, "</body></html>"
  2175.     call lineout tempfile  /* close */
  2176.    'FILE ERASE TYPE text/html NAME ' tempfile
  2177.    return 0
  2178. end  /* Do */
  2179. ngot=0
  2180. do mm=1 to dalines.0
  2181.     aline=upper(strip(dalines.mm))
  2182.     if aline=" " | abbrev(aline,';')=1  then iterate
  2183.     parse var aline p1 p2
  2184.     p1=translate(p1,' ','.')
  2185.     if words(p1)=1 & host_nickname<>' ' then iterate
  2186.     oo=word(p1,words(p1))
  2187.     if words(p1)>1 then do
  2188.         if datatype(oo)<>'NUM' then
  2189.             if upper(strip(oo))<>host_nickname then iterate
  2190.     end  /* Do */
  2191.     p10=p1 ; 
  2192.     if words(p1)>1 &  datatype(oo)<>'NUM' then
  2193.              p10=delword(p10,words(p10))
  2194.     ngot=ngot+1
  2195.     p2=a_replacestrg(p2,'<','<','ALL')
  2196.     p2=a_replacestrg(p2,'>','>','ALL')
  2197.     p2=a_replacestrg(p2,'"','"','ALL')
  2198.     users.ngot=translate(strip(p10),'.',' ')
  2199.    if length(p2)>60 then p2=left(p2,55)||' ...'
  2200.  
  2201.     users.ngot.2=left(p2,70)
  2202. end /* do */
  2203. if ngot=0 then do
  2204.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2205.     call lineout tempfile, "<html><head><title>No entries in replacement strings list</title></head>"
  2206.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2207.     if host_nickname<>' ' then
  2208.       call lineout tempfile,' <b>There are no replacement strings (for the ' host_nickname' Host) in: ' afile
  2209.     else
  2210.       call lineout tempfile,' <b>There are no replacement strings in: ' afile
  2211.     call lineout tempfile, "</body></html>"
  2212.     call lineout tempfile  /* close */
  2213.    'FILE ERASE TYPE text/html NAME ' tempfile
  2214.    return 0
  2215. end  /* Do */
  2216.  
  2217. /* now create a  list */
  2218. aa.1='<h2> Select Entries to Remove </h2> '
  2219. aa.2='<em>Unchecked entries will be retained <code>(the first 55 characters are displayed)</code></em>.<br>'
  2220. aa.3='<ol> '
  2221. do mm=1 to ngot
  2222.   fee=3+mm
  2223.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> (<code> == ' users.mm.2 '</code>'
  2224. end /* do */
  2225. fee=3+ngot+1
  2226. aa.fee='</ol>'
  2227. fee=fee+1
  2228. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2229.  
  2230. stuff2=aa.1
  2231. do mm=2 to fee
  2232.   stuff2=stuff2||crlf||aa.mm
  2233. end
  2234. return 1
  2235.  
  2236. * ----------------------------------------------------------------------- */
  2237. /* REPLACESTRG:
  2238.   Arguments:
  2239.                 astring : the "haystack" to look in
  2240.                 target: the "needle" to look for
  2241.                 putme: the "new needle" to replace the "needle" with
  2242.                 type : The direction/type of search
  2243.                         FORWARD, BACKWARD, ALL
  2244.                 exact: YES-- then cases in needle and haystack must match
  2245.  
  2246.       Note taht regardless of value of exact, cases are retained in both
  2247.       astring and putme.
  2248.  
  2249.    Returns the modified astring, or the unmodified astring if target could
  2250.    not be found.
  2251. */
  2252. /* ----------------------------------------------------------------------- */
  2253.  
  2254. a_replacestrg:
  2255.  
  2256. exactmatch=0
  2257. backward=0 ; doall=0
  2258.  
  2259. parse arg astring ,  target   , putme , type , exactmatch
  2260.  
  2261. type = translate(type)
  2262. if type="BACKWARD" then backward="YES"
  2263. if type="ALL" then doall="YES"
  2264.  
  2265. iat=1
  2266. joelen=length(target)
  2267. joelen2=length(putme)
  2268.  
  2269. doagain:                /* here if doall=yes */
  2270.  if exactmatch="YES" then do
  2271.     if   backward="YES" then
  2272.         joe= lastpos(target,astring)
  2273.     else
  2274.         joe= pos(target,astring,iat)
  2275.  end
  2276.  else do
  2277.    if   backward="YES" then
  2278.         joe= lastpos(translate(target),translate(astring))
  2279.     else
  2280.         joe= pos(translate(target),translate(astring),iat)
  2281.  end
  2282.  if joe=0 then
  2283.          return astring
  2284.  
  2285.  astring=delstr(astring,joe,joelen)
  2286.  if putme<>' ' then
  2287.     astring=insert(putme,astring,joe-1)
  2288.  
  2289.  if doall="YES" then do
  2290.      iat=joe+joelen2
  2291.      signal doagain
  2292.  end
  2293. /* else, all done */
  2294.  return astring
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.